package com.api.user.getusersbyid;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IUserApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.CollectionResultApi;
import com.zyncro.api.model.UserApi;

@ContextConfiguration(locations = { "classpath:/user/user-context.xml" })
public class GetUsersById extends AbstractApiTest {

	private static final int TOTAL_USERS = 3;

	@Value("#{org_users[mainAdmin].appId}")
	private String userId;

	@Value("#{org_users[mainAdmin].password}")
	private String userPassword;

	@Value("#{user_toFollow.appId}")
	private String targetUser0Urn;

	@Value("#{user_toUnfollow.appId}")
	private String targetUser1Urn;

	@Value("#{org_users[notContact].appId}")
	private String targetUser2Urn;

	@BeforeClass
	public void setUpVariables() {

		getApi().login(userId, userPassword);
	}

	@Test
	public void testGetProfiles() throws ZyncroApiException {

		boolean onlyShort = false;

		List<String> users = new ArrayList<String>();
		users.add(targetUser0Urn);
		users.add(targetUser1Urn);
		users.add(targetUser2Urn);

		CollectionResultApi<? extends UserApi> result = getApi().getService(IUserApiService.class).getUsersById(users, onlyShort);
		Assert.assertEquals(result.getElements().size(), TOTAL_USERS);
	}
}
